<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue入门指南-模板引用</title>
    <link rel="stylesheet" href="common.css">
    <script type="importmap">
        {
            "imports":{
                "vue":"http://lib.baomitu.com/vue/latest/vue.esm-browser.js"
            }
        }
    </script>
</head>
<body>
    <div id="app">
        <p>{{message}}</p>
        <input type="text" ref="myInput">
        <p><input type="text" :ref="setMyInput"></p>
    </div>
    <script type="module">
        import {createApp} from "vue";
        createApp({
            data() {
                return {
                    message:"模板引用使用特殊属性 ref,会在this.$refs暴露相应的对象"
                }
            },
            mounted(){
                this.$refs.myInput.focus();

                this.$refs.myInput.value="模板引用";
            },
            methods:{
                setMyInput(el){
                    el.value=el.nodeName;
                }
            }
        }).mount("#app")
    </script>
</body>
</html>
